import './App.scss';
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { ADDCOUNT_ACTION } from './store/actionCreator'
import GoodsList from './views/GoodsList'
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom'
//组件
import Prodetail from './views/ProDetail'
import { Header, Navigation, Search } from './views/Header'
import Footer from './views/Footer'
import Cart from './views/Cart'
import Kiss from './views/kiss'
// import axios from 'axios'
import Gird from './views/Gird'
import Oper from './views/Opers'
import Baby from './views/Baby'
// React.Component.prototype.$axios = axios

class App extends Component {
  render () {
    return (
      <Router>
        <div>
          <Header></Header>
          <Search searchItems={this.searchItems}></Search>
          <Navigation></Navigation>
          <Cart></Cart>
          {/* 重定向 */}
          <Route path='/' render={() => <Redirect to="/kiss" />}></Route>
          <Route path='/kiss' component={Kiss}></Route>
          <Route path="/goodslist/:Type/:type" component={GoodsList}></Route>
          <Route path="/prodetail/:Type/:type/:id" component={Prodetail}></Route>

          <Route path='/baby' component={Baby}></Route>
          <Route path="/gird" component={Gird}></Route>
          <Route path="/grid/oper" component={Oper}></Route>
          <Footer></Footer>
        </div>
      </Router>
    )
  }
  searchItems (search) {
    console.log(search)
  }
}

const mapStateToProps = (state) => {
  return state
}

const mapDispatchToProps = (dispatch) => {
  return {
    addCount () {
      dispatch(ADDCOUNT_ACTION())
    }
  }

}

export default connect(mapStateToProps, mapDispatchToProps)(App)

